Make GPX input modules optional.
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Tue, 29 Jul 2003 19:29:14 +0000 (19:29 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Tue, 29 Jul 2003 19:29:14 +0000 (19:29 +0000)
gpsbabel/Makefile
gpsbabel/geo.c
gpsbabel/gpx.c

index b20769b3938e9e730508bcb3e42c6fb36f99933d..5192352644297ef4606199adf352929f4fc36a25 100644 (file)
@@ -1,5 +1,12 @@
+
+# If you do not have libexpat and you have no use for reading any input
+# type that is XML-ish (i.e. gpx or geocaching.com's/loc) you can uncomment
+# INHIBIT_EXPAT and coment out LIBEXPAT on just to get a build working quickly.
+# INHIBIT_EXPAT=-DNO_EXPAT
+LIBEXPAT=-lexpat
+
 # add -DDEBUG_MEM to turn on memory allocation logging
-CFLAGS=$(EXTRA_CFLAGS) -g -Icoldsync
+CFLAGS=$(EXTRA_CFLAGS) -g -Icoldsync  $(INHIBIT_EXPAT)
 INSTALL_TARGETDIR=/usr/local/
 
 FMTS=magproto.o gpx.o geo.o mapsend.o mapsource.o \
@@ -29,7 +36,7 @@ OBJS = main.o $(LIBOBJS)
 all: gpsbabel
 
 gpsbabel: $(OBJS)
-       $(CC) $(CFLAGS) $(OBJS) -o gpsbabel -lexpat -lm
+       $(CC) $(CFLAGS) $(OBJS) -o gpsbabel $(LIBEXPAT) -lm
 
 main.o:
        $(CC) -c $(CFLAGS) -DVERSION=\"$(VERSIOND)\" $<
index 959669f55bd371cf8d7439a21d4a4cb4df4aa29d..0957387a658a48a9ee2c32388913f9c17e208b99 100644 (file)
 
  */
 #include "defs.h"
+#if !NO_EXPAT
 #include <expat.h>
+static XML_Parser psr;
+#endif
 
 static int in_wpt;
 static int in_name;
@@ -27,7 +30,6 @@ static int in_cdata;
 static char *cdatastr;
 static char *typestr;
 
-static XML_Parser psr;
 static waypoint *wpt_tmp;
 
 FILE *fd;
@@ -36,6 +38,18 @@ FILE *ofd;
 #define MYNAME "geo"
 #define MY_CBUF 4096
 
+#if NO_EXPAT
+void
+geo_rd_init(const char *fname, const char *args)
+{
+       fatal(MYNAME ": This build excluded GPX support becuase expat was not installed.\n");
+}
+
+void
+geo_read(void)
+{
+}
+#else
 static void
 tag_coord(const char **attrv)
 {
@@ -189,6 +203,25 @@ geo_rd_init(const char *fname, const char *args)
        XML_SetCharacterDataHandler(psr, geo_cdata);
 }
 
+void
+geo_read(void)
+{
+       int len;
+       char buf[MY_CBUF];
+       
+       while ((len = fread(buf, 1, sizeof(buf), fd))) {
+               if (!XML_Parse(psr, buf, len, feof(fd))) {
+                       fatal(MYNAME ":Parse error at %d: %s\n", 
+                               XML_GetCurrentLineNumber(psr),
+                               XML_ErrorString(XML_GetErrorCode(psr)));
+               }
+       }
+
+       XML_ParserFree(psr);
+}
+
+#endif
+
 void
 geo_rd_deinit(void)
 {
@@ -216,23 +249,6 @@ geo_wr_deinit(void)
        fclose(ofd);
 }
 
-void
-geo_read(void)
-{
-       int len;
-       char buf[MY_CBUF];
-       
-       while ((len = fread(buf, 1, sizeof(buf), fd))) {
-               if (!XML_Parse(psr, buf, len, feof(fd))) {
-                       fatal(MYNAME ":Parse error at %d: %s\n", 
-                               XML_GetCurrentLineNumber(psr),
-                               XML_ErrorString(XML_GetErrorCode(psr)));
-               }
-       }
-
-       XML_ParserFree(psr);
-}
-
 static void
 geo_waypt_pr(const waypoint *waypointp)
 {
index 9de09829b18d0bcb1144e2d2bd046e310979b475..5ed82708e36724293e2df329442d5db03364d443 100644 (file)
  */
 
 #include "defs.h"
-#include <expat.h>
+#ifndef NO_EXPAT
+       #include <expat.h>
+       static XML_Parser psr;
+#endif
 
 static int in_wpt;
 static int in_rte;
@@ -53,8 +56,6 @@ static char *cdatastr;
 static int opt_logpoint = 0;
 static int logpoint_ct = 0;
 
-static XML_Parser psr;
-
 static const char *gpx_version;
 static const char *gpx_creator;
 
@@ -671,6 +672,15 @@ gpx_end(void *data, const char *el)
        }
 }
 
+#if NO_EXPAT
+void
+gpx_rd_init(const char *fname, const char *args)
+{
+       fatal(MYNAME ": This build excluded GPX support becuase expat was not installed.\n");
+}
+
+#else /* NO_EXPAT */
+
 static void
 gpx_cdata(void *dta, const XML_Char *s, int len)
 {
@@ -761,6 +771,7 @@ gpx_rd_init(const char *fname, const char *args)
        XML_SetElementHandler(psr, gpx_start, gpx_end);
        XML_SetCharacterDataHandler(psr, gpx_cdata);
 }
+#endif
 
 static void
 gpx_rd_deinit(void)
@@ -795,6 +806,7 @@ gpx_wr_deinit(void)
 void
 gpx_read(void)
 {
+#ifndef NO_EXPAT
        int len;
        int done = 0;
        char buf[MY_CBUF];
@@ -822,6 +834,7 @@ gpx_read(void)
                                XML_ErrorString(XML_GetErrorCode(psr)));
                }
        }
+#endif /* NO_EXPAT */
 }
 
 /*